function prepareGallery() {
	if(!document.getElementById || !document.getElementsByTagName) return false;
	
	let imgGallery = document.getElementById("imagegallery");
	if(!imgGallery) return false;
	let links = imgGallery.getElementsByTagName("a");
	if(links.length < 1) return false;
	for(let i = 0; i < links.length; i++) {
		links[i].onclick = function() {
			return !showPic(this);
		}
		// links[i].onkeypress = links[i].onclick;
	}
}

function showPic(whichPic) {
	if(!document.getElementById) return false;
	
	let placeHolder = document.getElementById("placeholder");
	if(!placeHolder) return false;
	let imgDesc = document.getElementById("description");
	if(!imgDesc) return false;
	let source = whichPic.getAttribute("href");
	let imgTitle = whichPic.getAttribute("title");
	
	placeHolder.setAttribute("src", source);
	imgDesc.firstChild.nodeValue = imgTitle;
	return true;
}

function addLoadEvent(func) {
	let oldOnLoad = window.onload;
	if(typeof window.onload != 'function')
		window.onload = func;
	else {
		window.onload = function() {
			oldOnLoad();
			func();
		}
	}
}

addLoadEvent(prepareGallery);